package com.lsy.weizhi2.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lsy.weizhi2.R;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by 嗨哟 on 2017/4/1.
 */
public class CardPicAdapter extends RecyclerView.Adapter<CardPicAdapter.CartPicViewHolder> {
    private Context context;
    private List<?> list;
    private LayoutInflater layoutInflater;

    public CardPicAdapter(Context context, List<?> list) {
        this.context = context;
        this.list = list;
        layoutInflater=LayoutInflater.from(context);
    }

    @Override
    public CartPicViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = layoutInflater.inflate(R.layout.cart_pic_item,parent,false);
        AutoUtils.autoSize(view);
        return new CartPicViewHolder(view);
    }

    @Override
    public void onBindViewHolder(CartPicViewHolder holder, int position) {
        holder.position=position;
    }

    @Override
    public int getItemCount() {
        return list==null?6:list.size();
    }

    class CartPicViewHolder extends RecyclerView.ViewHolder{
        int position;
        RelativeLayout card_item_view;
        ImageView card_pic_iv;
        TextView card_pic_name,card_pic_num;
        public CartPicViewHolder(View itemView) {
            super(itemView);
            card_item_view= (RelativeLayout) itemView.findViewById(R.id.card_item_view);
            card_pic_iv= (ImageView) itemView.findViewById(R.id.card_pic_iv);
            card_pic_name= (TextView) itemView.findViewById(R.id.card_pic_name);
            card_pic_num= (TextView) itemView.findViewById(R.id.card_pic_num);
            card_item_view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                }
            });
        }
    }
}
